package hxy.scan.server.controller;

import hxy.scan.server.dao.model.LocationModel;
import hxy.scan.server.entity.BaseResponse;
import hxy.scan.server.service.LocationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author eric
 */
@Slf4j
@RestController
public class LocationController {

    @Resource
    private LocationService locationService;

    /**
     * 上报位置信息
     *
     * @param locationModel
     * @return
     */
    @PostMapping("location")
    public BaseResponse save(@RequestBody LocationModel locationModel) {
        return locationService.saveLocation(locationModel);
    }

    /**
     * 获取当前用户的位置信息
     *
     * @param userId
     * @param current
     * @return
     */
    @GetMapping("location")
    public BaseResponse get(Long userId, long current) {
        return locationService.getByUserId(userId, current);
    }

}
